#include <iostream>
#define MAXN 1000005
#define MOD 1000000000
using namespace std;
long long dp[MAXN];
bool used[MAXN];
int N;


int main() {
    cin >> N;
    for (int i = 1; i <= N; i *= 2) {
        used[i] = true;
    }
    dp[0] = 0; dp[1] = 1; dp[2] = 2;
    for (int i = 3; i <= N; i++) {
        if (i % 2) dp[i] = dp[i - 1];
        else dp[i] = dp[i - 1] + dp[i / 2];
        dp[i] %= MOD;
    }
    cout << dp[N] << endl;
}
